package io.renren.modules.workmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.workmanagement.dao.QuRepoDao;
import io.renren.modules.workmanagement.entity.QuRepoEntity;
import io.renren.modules.workmanagement.service.QuRepoService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("quRepoService")
public class QuRepoServiceImpl extends ServiceImpl<QuRepoDao, QuRepoEntity> implements QuRepoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<QuRepoEntity> page = this.page(
                new Query<QuRepoEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<QuRepoEntity> ListByQuestionId(Long id) {
        return this.lambdaQuery().eq(QuRepoEntity::getQuId, id).list();
    }

    @Override
    public void removeByQuId(Long id) {
        this.lambdaUpdate().eq(QuRepoEntity::getQuId, id).remove();
    }

    @Override
    public List<QuRepoEntity> listByQuIds(List<Long> quIds) {
        return this.lambdaQuery().in(QuRepoEntity::getQuId, quIds).list();
    }

    @Override
    public void removeByQuIds(List<Long> quIds) {
        this.lambdaUpdate().in(QuRepoEntity::getQuId, quIds).remove();
    }

    @Override
    public List<QuRepoEntity> listByQuBankId(Long quBankId) {
        return this.lambdaQuery().eq(QuRepoEntity::getRepoId, quBankId).list();
    }

    @Override
    public List<QuRepoEntity> listByBankIds(List<Long> bankIds) {
        return this.lambdaQuery().in(QuRepoEntity::getRepoId, bankIds).list();
    }

}
